Maven: Understanding Lifecycle, Phase and Plugin Goal by code

Categories: Development NotesJava February 11th, 2015 23:24

Lifecycle

There are same built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project’s site documentation.

the default lifecycle includes many phases, e.g: validate, initialize…compile, test, package, integration-test, verify, install and deploy.  check Maven 3 components.xml;

If you run one phase, e.g. install, it will execute not only that phase (install), but also every phase prior to the install phase;

Phases

A Build Phase is Made Up of Plugin Goals;

for maven 3.1, compile phase is using: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile;  get more details from default-bindings.xml

Plugin Goal

A plugin may have one or more goals wherein each goal represents a capability of that plugin.

plugins can contain information that indicates which lifecycle phase to bind a goal to. Note that adding the plugin on its own is not enough information – you must also specify the goals you want to run as part of your build. A plugin goal may be bound to zero or more build phases. A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation.

pom configuration examples:

maven compile: http://maven.apache.org/plugins/maven-compiler-plugin/usage.html

maven javadoc: http://maven.apache.org/plugins/maven-javadoc-plugin/usage.html

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.